package com.example.springboot_demo.controller;

import com.example.springboot_demo.pojo.ContrastBean;
import com.example.springboot_demo.service.DevService;
import com.example.springboot_demo.service.GovService;
import com.example.springboot_demo.service.MongoTestService;
import com.example.springboot_demo.service.TecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
 * @author 江岸
 * @version V1.0
 * @ClassName: MyController
 * @description: TODO
 * @date 2020/12/817:05
 * @since V1.0
 */
@RestController
@RequestMapping("/mytest")
public class MyController {
    @Autowired
    private MongoTestService mongoTestService;
    @Autowired
    private GovService govService;
    @Autowired
    private DevService devService;
    @Autowired
    private TecService tecService;


    @RequestMapping("findAll")
    public Object findAll() {
        List<ContrastBean> all = mongoTestService.findAll();
        return all;
    }

    @RequestMapping("medical/condition")
    public Object medicalCondition() {
        mongoTestService.medicalCondition();
        return null;
    }


    @RequestMapping("gov/document")
    public Object govDocument() {
        //并购,兼并，收购，重组
        List<String> list = Arrays.asList("并购", "兼并", "收购", "重组");
        //08年到20年
        for (int year = 2023; year <2024 ; year++) {
            for (String key : list) {
                govService.getPage(key,year);
            }
        }
        return null;
    }

    @RequestMapping("gov/all")
    public Object queryAll() {
        //并购
        Set<String> fromDb = govService.getFromDb();
        return fromDb;
    }

    @RequestMapping("dev/document")
    public Object devDocument() {
        //并购,兼并，收购，重组
//        List<String> list = Arrays.asList("并购", "兼并", "收购", "重组");
        //        List<String> list = Arrays.asList("%E5%B9%B6%E8%B4%AD", "%E5%85%BC%E5%B9%B6", "%E6%94%B6%E8%B4%AD", "%E9%87%8D%E7%BB%84");

        //08年到20年
//        for (int year = 2008; year <2024 ; year++) {
                devService.getPage("%E9%87%8D%E7%BB%84",1);
//        }
        return null;
    }

    @RequestMapping("tec/document")
    public Object tecDocument() {
        //并购,兼并，收购，重组
        List<String> list = Arrays.asList("并购", "兼并", "收购", "重组");
//        List<String> list = Arrays.asList("%E5%B9%B6%E8%B4%AD", "%E5%85%BC%E5%B9%B6", "%E6%94%B6%E8%B4%AD", "%E9%87%8D%E7%BB%84");
        //08年到20年
        for (int year = 2021; year <2024 ; year++) {
            for (String key : list) {
                tecService.getPage(key,year);
            }
        }
        return null;
    }

}
